package likou.tanxin;

/**
 * @author: Tangxz
 * @email:1171702529@qq.com
 * @cate: 2020/11/03 08:06
 */
//情侣牵手
public class _765 {
    public int minSwapsCouples(int[] row) {
        int ans = 0;
        for (int i = 0; i < row.length; i += 2) {
            int x = row[i];
            //异或1，把第一个二进制数取反
            if (row[i+1] == (x ^ 1)) {
                continue;
            }
            ans++;
            for (int j = i+1; j < row.length; ++j) {
                if (row[j] == (x^1)) {
                    row[j] = row[i+1];
                    row[i+1] = x^1;
                    break;
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(1^1);
        System.out.println(0^1);
        System.out.println(9^1);
        System.out.println(10^1);
        System.out.println(7^1);
        System.out.println(8^1);
    }

}
